Command buttons Directory Opus has tons of internal commands, but you, as the
user, can define commands of your own which act just like DOpus' internal ones. The
easiest way to explain this great feature is (like so many other things) through an
example or two.
Let's suppose that you (like myself) have the same function defined in several places;
for example, you may have an image viewer (in this case CyberView) defined in a pull down
menu, a toolbar button, and a filetype, all of which execute the following function:
Work:Graphics/CyberView/CyberView CENTER WIDTH=800 HEIGHT=600 CORRUPT {F!}
Well, if you wanted to change (let's say) the resolution to WIDTH=1024 HEIGHT=768, then
you would have to do that for all locations of the function (plus you may not even forget
one).
So, the easiest way to manage multiple occurrences of the same function is to define a
command for it.
Let's look at how to make a command which makes Multiview open an image on its own
screen. First, we need to get into the function editor, so we'll simply select New ยป
Graphics Buttons... from the Buttons Menu. Double-click on the new button to open the
button editor. Next, double-click on "Left" under "Functions" in the
button editor; this will reveal the function editor.
Once you have the function editor open, select "Add" and enter the following
text:
SYS:Utilities/Multiview SCREEN {F}
Change the function type to AmigaDOS (by default it will be set to Workbench). Now from
the Edit pull-down menu (which you may not have known was there ;-) select "Export As
Command File..." (shortcut:
f).
Enter the name for your command - something like "Multiview". The command is
then saved into DOpus5:Commands/ - go see!
Now, go back to the function editor (which should still be open) and select Delete to
delete this function we entered (as it is now saved as a command anyway). Click
"Add" (and leave the type as Command), and then click on the Command List button
(which looks like a file folder - to the right of the command-type cycle-menu). In the
list you should see your command! But wait, it has no definition like all the other
commands.
Open a lister which contains the path DOpus5:Commands/ and hold down the right mouse
button over your command. Select "Edit Command..." from the pop-up menu. Without
changing anything, select save. A DOpus requestor will open: turn off "Leave out on
desktop" and enter a description into the text field. Once you hit OK, your command
will have a description.
By the way, you may now discard the graphic button we created at the beginning, since
it was only used to get at the function editor.
|
You can also add/change the command description by editing the command file's comment
field using the internal Comment command. Or, if you have the command field enabled in
name mode listers, you can use in-line editing to add/change the command description as
well! |
|
Another great example of a user-defined command one used to play random samples. You can
then add it to each button on a button bank so that when you click on the buttons they
play a random sound.
Using PickFile and DSound (both available on Aminet), I have set up a command called
RandSample which looks like:
AmigaDOS PickFile F=Samples:MiscSamples.list Q C=C:Run C:DSound -2 -w
Samples:Misc/[].snd
This line simply tells PickFile to look select a sample from MiscSamples.List and play
it using DSound (read the programs' respective documentation for further details).
Now you can set up a button which might look like this:
Command RandSample
Command SmartRead
Which would launch DOpus' internal SmartRead after playing a cool sound...